package com.itheima.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo01Servlet")
public class Demo01Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.处理请求乱码
        //request.setCharacterEncoding("utf-8");
        //2.获取请求参数
        String username = request.getParameter("username");
        System.out.println("username = " + username);
        //3.输出
        System.out.println("demo01Servlet。。。。正在执行");
        //4.处理响应乱码
        //response.setContentType("text/html;charset=utf-8");
        //5.响应数据
        response.getWriter().print("欢迎来到这个世界!!!");

    }
}